package com.example.treeutil.model.anno;

import com.example.treeutil.tree.NodeValue;

/**
 * 2022/12/9
 * 目录下具体资源
 * @author fengyu
 */
@NodeValue(isCatalog = false)
public class Apple {
    @NodeValue(field = NodeValue.FIELD.ID)
    private String id;

    @NodeValue(field = NodeValue.FIELD.PID)
    private String pid;

    private String 品种;
    private int index;
    private String 产地;

    public Apple(){}
    public Apple(String id, String pid, String type, String 产地, int index) {
        this.id = id;
        this.pid = pid;
        this.品种 = type;
        this.产地 = 产地;
        this.index = index;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public String get品种() {
        return 品种;
    }

    public void set品种(String 品种) {
        this.品种 = 品种;
    }

    @NodeValue(method = NodeValue.METHOD.GET_INDEX)
    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public String get产地() {
        return 产地;
    }

    public void set产地(String 产地) {
        this.产地 = 产地;
    }

    /**
     * 如果没有这个注解方法，则判断注解NodeValue.FIELD.PID是否为空
     * @return
     */
    @NodeValue(method = NodeValue.METHOD.HAS_PARENT)
    public boolean hasParent(){
        return pid != null && pid.length() > 0;
    }
}
